<template>
	<!-- 用户列表 -->
	<div>
		<common-table :userData='userData'></common-table>
		<el-pagination
		  background
		  @current-change='currentNum'
		  layout="prev, pager, next"
		  :total="userData.data.meta.pagination.total">
		</el-pagination>
	</div>
</template>

<script>
	import commonTable from '../../../../components/Table/commonTable.vue'
	export default{
		components:{
			commonTable
		},
		data(){
			return{
				userData:[],
				// 用户点击分页按钮时,当前的页数,默认是当前数组的第一页数据
				current_page:1,
				
			}
		},
	    methods:{
			// 请求用户数据
		    async getUserData(){
				
				const params={
					current:this.current_page
				}
				await this.axios.get('/api/admin/users',params).then(res=>{
					console.log(res);
					
					this.userData=res
				}).catch(err=>{
					console.log(err)
				})
			},
			// 点击获取当前页数
			currentNum(page){
				console.log(page);
				this.current_page=page;
				this.userData=[]
				this.getUserData(this.current_page)
			}
		},
		created(){
			this.getUserData()
		}
	}
	
</script>

<style scoped="scoped">
	.el-main{
		line-height: 0px !important;
	}
</style>
